package com.vitabuybuy.tv.ui.tencent.liveroom.roomutil.widget

import android.content.Context
import android.view.View
import android.view.animation.Animation
import android.widget.TextView
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.library.common.ext.setOnclick
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.PopupAllLimitedGroupBinding
import com.vitabuybuy.tv.databinding.PopupGiftQuantityBinding
import razerdp.basepopup.BasePopupWindow
import razerdp.util.animation.AnimationHelper
import razerdp.util.animation.ScaleConfig
import razerdp.util.animation.TranslationConfig

/**
 * 删除弹出框
 */
class GiftQuantityPopup(
    context: Context,
    private var onConfirm: (quantyty: String) -> Unit
) : BasePopupWindow(context) {

    private lateinit var mBinding: PopupGiftQuantityBinding


    override fun onCreateContentView(): View {
        return createPopupById(R.layout.popup_gift_quantity)
    }

    override fun onViewCreated(contentView: View) {
        super.onViewCreated(contentView)
        mBinding = DataBindingUtil.bind<ViewDataBinding>(contentView) as PopupGiftQuantityBinding
        setOnclick(
            mBinding.tvQuantity1,
            mBinding.tvQuantity5,
            mBinding.tvQuantity10,
            mBinding.tvQuantity20,
            mBinding.tvQuantity66,
            mBinding.tvQuantity100
        ) {
            onConfirm.invoke((it as TextView).text.toString())
            dismiss()
        }
    }

    override fun onCreateShowAnimation(): Animation {
        return AnimationHelper.asAnimation()
            .withTranslation(TranslationConfig.FROM_BOTTOM)
            .toShow()
    }

    override fun onCreateDismissAnimation(): Animation {
        return AnimationHelper.asAnimation()
            .withTranslation(TranslationConfig.TO_BOTTOM)
            .toDismiss()
    }
}